package com.beizhen.demo.controller;

import com.beizhen.demo.entity.StuTripPlan;
import com.beizhen.demo.entity.StuTripStudent;
import com.beizhen.demo.service.StuEvaluateService;
import com.beizhen.demo.service.StuTripPlanService;
import com.beizhen.demo.service.StuTripStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.WebRequest;

import java.util.ArrayList;
import java.util.List;

/**
*  前端控制器
*/
@Controller
    public class StuEvaluateController {
    @Autowired
    private StuEvaluateService stuEvaluateService;

    @Autowired
    private StuTripStudentService studentService;

    @Autowired
    private StuTripPlanService stuTripPlanService;

    @RequestMapping("/goEvaluate")
    public String goEvaluate(){
        return "school/school_evaluate_administration_insert";
    }

    @RequestMapping("/selStuTripPlanByValue")
    public String selStuTripPlanByValue(WebRequest webRequest){
        int b_id = 1;
        List<StuTripPlan> planList = stuTripPlanService.sel_StuTripPlan(b_id);
        List<StuTripStudent> classList = new ArrayList<StuTripStudent>();
        for(StuTripPlan s : planList){
            classList = studentService.selStuById(s.getTClass());
        }
        webRequest.setAttribute("classList",classList, RequestAttributes.SCOPE_REQUEST);
        webRequest.setAttribute("stuTripPlan",planList, RequestAttributes.SCOPE_REQUEST);
        return "school/school_evaluate_administration_insert";
    }
}
